<?php
//session_start();
require_once '../models/Customer.php';
	$session_customer_id=0;
	$session_customer_email;
	// there is an admin value in session
	if(isset($_SESSION["session_customer_email"])&&isset($_SESSION["session_customer_password"])){
		$session_customer_email=$_SESSION["session_customer_email"];
		$session_customer_password=$_SESSION["session_customer_password"];
		// check user and password
		$row=Customer::checkCustomerLogin($session_customer_email,$session_customer_password);
		if(isset($row['customerID'])){
			$status=$row['status'];
			// check user status
			if($status==USER_VALUE_ACTIVE){
				$session_customer_id=(int)$row['customerID'];
				$session_customer_fullName=$row['f_name'].' '.$row['l_name'];
				$session_customer_email=$row['email'];
			}
		}else{
			$session_customer_id=-1;
		}
	}
	// check login
	if(!isset($session_customer_id)||$session_customer_id==0){
		header('Location: ../views/login.php');
	}
	// check session
	if($session_customer_id==-1){
		header('Location: ../views/login.php');
	}

?>